package com.yangyang.rpc.core.serialize;

import com.yangyang.rpc.core.serialize.impl.HessianSerializer;
import com.yangyang.rpc.core.serialize.impl.JacksonSerializer;
import com.yangyang.rpc.core.serialize.impl.ProtostuffSerializer;

/**
 * Created by chenshunyang on 2016/11/19.
 */
public enum  SerializeEnum {

    HESSIAN(new HessianSerializer()),
    PROTOSTUFF(new ProtostuffSerializer()),
    JSON(new JacksonSerializer());

    public Serializer serializer;

    private  SerializeEnum(Serializer serializer){
        this.serializer = serializer;
    }

    public static SerializeEnum match(String name, SerializeEnum defaultSerializer){
        for (SerializeEnum item : SerializeEnum.values()) {
            if (item.name().equals(name)) {
                return item;
            }
        }
        return defaultSerializer;
    }

}
